-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Remove the hardcoded border=1 in the to_html dataframe export. #4578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Remove the hardcoded border=1 in the to_html dataframe export. #4578
Conversation
The border is impossible to overwrite at later stage, therefore using no border gives the user the possibility to style the table, using CSS Classes.
can you add a release notes entry? edit doc/source/releast.rst is it possible to post a picture here of before/after? |
thanks for the pic! ok....I actually like the border (my 2cents)...is that a way to do this such that you can do the css, while providing a default that has the border? (so existing behavior is maintained but you can override)? |
@jreback I'm not sure if there is a quick way to achieve that. What we could do is to have The problem is It may be possible, not too sure it's savvy. |
I think the way to solve this is to add a display option to control this see I think there is only 1 existing notebook option, so maybe add another (under the display name space)
|
that's it, after |
@jreback That makes sense, but preferable that outputted html doesn't have a border attribute at all if it's set to I.e.
|
as you guys are the CSS experts, I think @mattions wants to say set |
@jreback that's a nice way to do it, because then you can just inject CSS into the notebook separately via IPython. Way easier to maintain for pandas too. |
that might be a nice to way to have default formatters for the |
@mattions can you update to use the option syntax to control this? |
@jreback I'm sorry I don't understand the option you are referring to. |
I would like you to add an option, |
@@ -571,7 +571,7 @@ def write_result(self, buf): | |||
'not %s') % type(self.classes)) | |||
_classes.extend(self.classes) | |||
|
|||
self.write('<table border="1" class="%s">' % ' '.join(_classes), | |||
self.write('<table class="%s">' % ' '.join(_classes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What jreback means is to do the following right here
if get_option('notebook.style.border'):
fmt = '<table border="%d" class="%%s"> ' % get_option('notebook.style.border')
else:
fmt = '<table class="%s">'
self.write(fmt % ' '.join(_classes)
And then somewhere in the file add:
border_ doc = """
: integer or string
Border width to be set via table border property
"""
config.register_option('notebook.style.border', 1, border_doc, None)
The orig issue was concerned with control over the output of Using the option mechanism to control exporting style breaks with the existing If you must add this option, I think it can comfortably join it's bretheren under the Again, keeping in mind the original issue this seems like the wrong thing to me. 2c. |
so what's the right way forward @y-p? |
I think templates are the goal ... maybe we can move the discussion there? in particular the API should be decided on and then I or someone else can start working on it |
(#3190) |
what did we decide for this? option to control the border width? templates in 0.14? |
i'm a strong +1 on templates |
agreed....should we do anything in 0.13 for this? |
defering this to 0.14. This very valid, thanks for the PR; the problem is adding this now could complicated the refactor for deal with a templated style system that is slated for 0.14. Feel free to contribute on that (and this will definitley be included, maybe via a slightly different mechanism). |
I've commited to getting a more general solution for styling HTML output/generating output closing. |
The border is impossible to overwrite at later stage, therefore using no
border gives the user the possibility to style the table, using CSS Classes.